package org.micode.common.helper;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.LoggerContext;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.LoggerFactory;

@Slf4j
public class LoggerHelper {

    private static LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();

    public static Boolean resetLogLevel(
            String loggerName, String levelName) {
        try {
            loggerContext.getLogger(loggerName).setLevel(Level.toLevel(levelName));
            return true;
        } catch (Exception e) {
            log.warn("Reset the level of log failed", e);
            return false;
        }
    }

}
